#include "login.h"
#include "ui_login.h"
#include<QDebug>
login::login(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::login)
{
    ui->setupUi(this);
    //this指当前窗口自己
    // 关键：初始化界面，将 .ui 中设计的控件加载到当前窗口
    setWindowTitle("0921");
    setWindowIcon(QIcon(":/1.jpg"));
}

login::~login()
{
    delete ui;
}






void login::on_pushButton_clicked()
{
   //获取注册信息
    QString strUser=ui->lineEdit_user->text();
    QString strTel=ui->lineEdit_tel->text();
    QString strPassword=ui->lineEdit_pass->text();
   //
    qDebug()<<strUser<<":"<<strTel<<":"<<strPassword;
    STRU_REGISTER_RQ srr;
    strcpy(srr.m_szName,strUser.toLocal8Bit());
    strcpy(srr.m_szPassword,strPassword.toStdString().c_str());
    srr.m_tel=strTel.toLongLong();
    m_pKernel->sendData((char*)&srr,sizeof(srr));
}



void login::slots_register(STRU_REGISTER_RS *psrr)
{

    if(psrr->m_szResult==registersuccess){
        QMessageBox::information(this,"tip","registersuccess");
    }
    else{
        QMessageBox::information(this,"tip","registerfail");

    }


}

void login::on_pushButton_2_clicked()
{
    QString strUser=ui->lineEditloginuser->text();
    QString strPassword=ui->lineEditloginpaword->text();
    STRU_LOGIN_RQ slr;
    strcpy(slr.m_szName,strUser.toLocal8Bit());
    strcpy(slr.m_szPassword,strPassword.toStdString().c_str());
    m_pKernel->sendData((char*)&slr,sizeof(slr));

}

